using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
//using MySql.Data.MySqlClient;
using System.Data;
using System.Data.SqlClient;
namespace Test {
	class Msk {
		static void MainX() {
			Settings set=new Settings("msq");
			//YSQL dml=new YSQL(set["cs"]);
			MSQL dml=new MSQL(set["cs"]);
			
			//DataTable tab=dml.Query("select count(*) from test01");
			//DataTable tab=dml.Query("truncate table test01");
			//DataTable tab2=dml.Query("show indexes in test01");
			//DataTable tab3=dml.Query("drop index ix_val1 on test01");
			for(int j=0;j<400;j++)
			{
				System.Diagnostics.Stopwatch sw=System.Diagnostics.Stopwatch.StartNew();
				for(int i=0;i<1000;i++)
					dml.NonQry(string.Format("insert into test01(val1,val2)values('{0}','{1}')",Guid.NewGuid().ToString("n"),Guid.NewGuid().ToString("n")));
				Console.WriteLine(sw.Elapsed);
			}
			string.Format("asddas");
		}
		//MySqlConnection con=new MySql.Data.MySqlClient.MySqlConnection(set["cs"]);
		////string sql="create table test01(id int auto_increment primary key,val1 varchar(50),val2 varchar(50))";
		//con.Open();
		//string sql=string.Format("insert into test01(val1,val2)values('{0}','{1}')",Guid.NewGuid(),Guid.NewGuid());
		//MySql.Data.MySqlClient.MySqlCommand cmd=new MySql.Data.MySqlClient.MySqlCommand(sql,con);
		//int ret=cmd.ExecuteNonQuery();
		//con.Close();
		//DataTable tab=new DataTable();
		//MySqlDataAdapter adp=new MySqlDataAdapter("select * from test01",con);
		//adp.Fill(tab);

	}

	class YSQL {

		public YSQL(string cs) {
			_cs=cs;
			//con=new MySqlConnection(_cs);
			//con.Open();
			//Console.WriteLine("OPEN");

		}
		~YSQL() {

			//con.Close();
			//Console.WriteLine("CLOSE");
		}
		//MySqlConnection con;
		string _cs;

		public DataTable Query(string sql,params object[] args) {
			string qry=string.Format(sql,args);
      DataTable ret=new DataTable();
      //using(MySqlDataAdapter adp=new MySqlDataAdapter(qry,_cs))
      //{
      //  adp.SelectCommand.CommandTimeout=180;
      //  adp.Fill(ret);
      //}
			return ret;
		}
		public int NonQry(string sql) {
			int ret=-1;
      //using(MySqlConnection con=new MySqlConnection(_cs))
      //using(MySqlCommand cmd=new MySqlCommand(sql,con))
      //{
      //  con.Open();
      //  ret=cmd.ExecuteNonQuery();
      //  con.Close();
      //}
			return ret;
		}

	}
	class MSQL {
		public MSQL(string cs) {
			_cs=cs;
			//con=new SqlConnection(_cs);
			//Console.WriteLine("OPEN");
			//con.Open();

		}
		~MSQL() {

			//con.Dispose();
			//if(con.State==ConnectionState.Open)
			//con.Close();
			//Console.WriteLine("CLOSE");
		}
		//SqlConnection con;
		string _cs;

		public DataTable Query(string sql,params object[] args) {
			string qry=string.Format(sql,args);
			DataTable ret=new DataTable();
			using(SqlDataAdapter adp=new SqlDataAdapter(qry,_cs))
			{
				adp.SelectCommand.CommandTimeout=180;
				adp.Fill(ret);
			}
			return ret;
		}
		public int NonQry(string sql) {
			int ret=-1;
			using(SqlConnection con=new SqlConnection(_cs))
			using(SqlCommand cmd=new SqlCommand(sql,con))
			{
				con.Open();
				ret=cmd.ExecuteNonQuery();
				con.Close();
			}
			return ret;
		}

	}
}
/*
I solved in this way: I logged in with root username
mysql -u root -p -h localhost
I created a new user with
CREATE USER 'francesco'@'localhost' IDENTIFIED BY 'some_pass';
//set password for 'francesco'@'localhost'=password('some_pass');--alter
then I created the database
CREATE DATABASE shop;
I granted privileges for new user for this database
GRANT ALL PRIVILEGES ON shop.* TO 'francesco'@'localhost';
Then I logged out root and logged in new user
quit;
mysql -u francesco -p -h localhost
I rebuilt my database using a script
source shop.sql;
And that's it.. Now from php works without problems with the call
$conn = new mysqli("localhost", "francesco", "some_pass", "shop");
Thanks to all for your time :)

create database test
create table test01(id int identity primary key,val1 varchar(50),val2 varchar(50))
create index ix_test01_val1 on test01(val1)
*/